#ifndef EDITDIALOG_H
#define EDITDIALOG_H

#include <head/g_pch.h>
#include <head/m_message.h>

namespace Ui {
class EditDialog;
}

class EditDialog : public QDialog
{
    Q_OBJECT

public:
    explicit EditDialog(const QSqlDatabase &db,
            QWidget *parent = nullptr);
    ~EditDialog();

    void prepareStatement(const QMap<QString, QString> &map);

    void transNameByCode(const QString &code,
                         const QString &getNameByCode,
                         QLineEdit &nameEdit);

    void transCodeByName(const QString &name,
                         const QString &getCodeByName,
                         QLineEdit &codeEdit);

    void updateAction(const QString &personCode,
                      const QString &depCode,
                      const QString &busCode);

    void appendMessage(const QString &message);

signals:
    void transferLog(const QString &log);

private slots:
    void on_btn_query_clicked();
    void on_btn_edit_clicked();

    void on_btn_personTransL_clicked();
    void on_btn_personTransR_clicked();
    void on_btn_depTransL_clicked();
    void on_btn_depTransR_clicked();

private:
    Ui::EditDialog *ui;

    QSqlDatabase _db;
    QMap<QString,QString> statements;
};

#endif // EDITDIALOG_H
